import {isEmpty} from '@/utils/CommonUtils';
import {onMounted, ref, watch} from 'vue';
import {getAction} from '@/request/BaseRequest';
import './style.css';

export default (props) => {
  let historys = ref([]);
  let loading = ref(false);

  function setHistory(result) {
    historys.value = result;
  }

  function loadHistory() {
    let businessId = props.businessId;
    if (isEmpty(businessId)) return;
    loading.value = true;

    getAction('/plat/loadFlowHistoryByBusInessId', {businessId}).then(data => {
      loading.value = false;
      if (data.success) {
        let result = data.result;
        setHistory(result);
      }
    });
  }

  onMounted(() => {
    loadHistory();
  });
  watch(() => props.businessId, loadHistory);
  return {
    historys,
    loading
  };
}

